<template>
	<!-- 展示每个人自己的三进记录 -->
	<view class="root-wrapper">	
		<u-row style="margin: 30rpx 0;">
			<u-col :span="12" class="my-sub-title" style="text-align: center;">
					{{ filter_time }}
					<u-icon 
						name="arrow-down" 
						@click="filter_timer_show = true">
					</u-icon>
			</u-col>
		</u-row>
		
		<!-- 时间过滤选择 -->
		<u-picker
			mode="time" 
			v-model="filter_timer_show" 
			:params="time_params" 
			@confirm="filterTimeConfirm">
		</u-picker>
	
		<history-trienter-card
			v-for="(item,index) in l" 
			:key="index"
			v-bind:info="item" 
			v-bind:key="index">
		</history-trienter-card>
		
		<view v-if="l.length === 0" style="text-align: center; margin-top: 30rpx;">暂无数据</view>
	
	</view>
</template>

<script>
	import historyTrienterCard from '../../components/history-trienter-card.vue'
	export default {
		components: {
			historyTrienterCard
		},
		
		onLoad() {
			this.$u.api.getTrienterHistory({
				date: ''
			}).then(res => {
				console.log(res)
				this.l = res.data
				this.l_backup = res.data
			})
		},
		
		data() {
			return {
				l:[],
				l_backup: [],
				filter_timer_show: false,
				filter_time: '按时间过滤',
				
				time_params: {
					year: true,
					month: true,
					day: true,		
				}
			}
		},
		methods:{
			filterTimeConfirm(e) {
				this.filter_time = e.year + '-' + e.month + '-' + e.day
				this.l = this.l_backup.filter(ele => {
					return this.$time_formatter.just_keep_date(ele.insertTime) === this.filter_time
				})
				// this.$emit('time_filter_change', this.filter_time)
			}
			
		}
	}
</script>

<style>
	
</style>
